Docker Local Deployment

How to deploy the MDriven Server and Turnkey on your local machine.

Start by installing Docker Desktop. Docker Desktop is mainly for managing containers so installing it is optional.

-------------------- Folder Structure ------------------

\---Apps
    |   compose.yaml                    - [configuration file for starting the MDriven Turnkey and Server as services]
    |   MDrivenServer.Dockerfile        - [Docker file for creating MDriven Server container image]
    |   MDrivenTurnkey.Dockerfile       - [Docker file for creating MDriven Turnkey containere image]
    \---turnkey-settings
        |   HardServerUrl.xml           - [Setting for specifying the URL to be used by the Turnkey Server]
        |   MDrivenServerOverride.xml   - [Settings for the Turnkey to connect to the MDriven Server]

MDrivenServer Dockerfile

i) Start with a base image of a Linux distribution

ii) Install the .NET SDK. For this case, we will use a Microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and Linux flavour from https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md.

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine

iii) Copy the MDriven Server files to the image or download the latest MDriven Server and extract it into the image.

RUN apk add --upgrade --no-cache \
        curl \
        unzip \
        xmlstarlet 

WORKDIR /app

ARG MS_VERSION

RUN curl -O https://mdriven.net/PublicDownloads/MDrivenServerOnCoreVersion.xml \
    && MS_VERSION=$(xmlstarlet sel -t -v "//root/date" MDrivenServerOnCoreVersion.xml) \
    && rm -f MDrivenServerOnCoreVersion.xml \
    && curl -O "https://mdriven.net/PublicDownloads/MDrivenServerCoreLinux_${MS_VERSION}.zip" \
    && unzip "MDrivenServerCoreLinux_${MS_VERSION}.zip" \
    && rm -f "MDrivenServerCoreLinux_${MS_VERSION}.zip"

Install Curl, unzip and xmstarlet packages for downloading and extracting the latest version of the MDriven Server for Linux. It is important to clean up residue files from upgrading Linux packages and file downloads. This is to keep the image size from getting overly big.

MDriven Server Current Version: https://mdriven.net/PublicDownloads/MDrivenServerOnCoreVersion.xml

MDriven Server Download Source: https://mdriven.net/PublicDownloads/MDrivenServerCoreLinux_<<MDriven Server Version>>.zip

iv) Set the package source for VistaDB

RUN dotnet nuget add source /mnt/c/capableobjectswush/Xternal/VistaDB --name  XternatVistaDB

v) Lastly start the MDriven Server

ENTRYPOINT ["dotnet", "AppCompleteGenericCore.dll", "-port=5010", "-nohttps"]

MDriven Turnkey Dockerfile

i) Start with a base image of a Linux distribution

ii) Install the .NET SDK. For this case, we will use a Microsoft base image that is packaged with the .NET SDK. Choose an image based on the .NET SDK version to use and Linux flavour from https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md.

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine

iii) Copy the MDriven Turnkey files to the image or download the latest MDriven Turnkey and extract it into the container.

RUN apk add --upgrade --no-cache \
        curl \
        unzip \
        xmlstarlet \
        musl-locales

ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

RUN locale -a

WORKDIR /app

ARG TK_VERSION

RUN curl -O https://mdriven.net/PublicDownloads/MDrivenTurnkeyOnCoreVersion.xml \
    && TK_VERSION=$(xmlstarlet sel -t -v "//root/date" MDrivenTurnkeyOnCoreVersion.xml) \
    && rm -f MDrivenTurnkeyOnCoreVersion.xml \
    && curl -O "https://mdriven.net/PublicDownloads/MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip" \
    && unzip "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip" \
    && rm -f "MDrivenTurnkeyCoreLinuxMUSL_${TK_VERSION}.zip"

Install Curl, unzip and xmstarlet packages for downloading and extract the latest version of the MDriven Server for Linux. Install locale settings if they are not available in the Linux image and set language. It is important to clean up residue files from upgrading Linux packages and file downloads. This is to prevent the image size from becoming overly big.

Turnkey Current Version: https://mdriven.net/PublicDownloads/MDrivenTurnkeyOnCoreVersion.xml

Turnkey Download Source (Alpine): https://mdriven.net/PublicDownloads/MDrivenTurnkeyCoreLinuxMUSL_<<Turnkey Version>>.zip

Turnkey Download Source (Ubuntu): https://mdriven.net/PublicDownloads/MDrivenTurnkeyCoreLinux_<<Turnkey Version>>.zip

iv) Copy the Turnkey Settings into the App_Data folder.

COPY ./turnkey-settings ./App_Data

Contents of turnkey-settings/HardServerUrl.xml

<?xml version="1.0" encoding="utf-8"?>
<root HardServerUrl="http://localhost:5020">
</root>

Contents of turnkey-settings/MDrivenServerOverride.xml

<?xml version="1.0" encoding="utf-8"?>
<root>
  <MDrivenServerOverride MDrivenServerPWD="123456" MDrivenServerUSER="a">http://mdriven_server:5010</MDrivenServerOverride>
</root>

v) Lastly, start the MDriven Turnkey.

ENTRYPOINT ["dotnet", "StreaminAppCoreWebApp.dll", "-port=5020", "-nohttps"]

Compose File

The Compose file is a single configuration file for building and starting the container images for the MDriven Server and MDriven Turnkey.

services:
  mdriven_server:
    build:
      dockerfile: MDrivenServer.Dockerfile
    networks:
      - app_net
    volumes:
      - mdriven_server_data:/app
    ports:
      - 5010:5010
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5010"]
      interval: 1h
      timeout: 30s
      retries: 5
      start_period: 30s

  mdriven_turnkey:
    build:
      dockerfile: MDrivenTurnkey.Dockerfile
    networks:
      - app_net
    volumes:
      - mdriven_turnkey_data:/app
    ports:
      - 5011:5011
    depends_on:
      - mdriven_server

volumes:
  mdriven_turnkey_data:
  mdriven_server_data:
networks:
  app_net:

mdriven_server: creates a service for the MDriven Server using the MDrivenServer.Dockerfile file. The MDriven Server is connected to and available in the app_net network. The service is binding port 5010 on your host machine to 5010 port on which the MDriven Server is running in the container. The volume is added to persist the MDriven Server files in the /app folder where it is currently located and running in the container. This allows for updating the Linux OS packages and images while leaving your Server data intact. Without a volume, the server data is destroyed when the container stops running.

The healthcheck: on the MDriven Server is to solve the issue of Vista DB locking itself. A check is performed after every hour and the server is restarted to clear the lock state. The healthcheck interval can be reduced based on the expected availability of the server.

mdriven_turnkey: creates a service for the MDriven Turnkey using the MDrivenTurnkey.Dockerfile file. The MDriven Turnkey is connected to and available in the app-net network. The service is binding port 5020 on your host machine to 5020 port on which the MDriven Turnkey is running in the container. The volume is added to persist the MDriven Turnkey files in the /app folder where it is currently located and running in the container.

Adding depends_on: ensures the Turnkey service only starts after the MDriven Server has started.

app_net: is a network shared by the two services so that they can communicate to each other.

How To Run Setup

Within the /Apps folder, run

docker compose up -d

See also:

This page was edited 33 days ago on 11/19/2024. What links here